const Router = require('koa-router');

const {tokenValidator} = require('../middleware/auth.middleware');
const {itemsFormValidator, idValidator} = require('../middleware/validate.middleware');
// 业务路由拆分 -- controller层
const {addItems, updateItems, queryItems, queryItemsDetail, deleteItems} = require('../controller/items.controller');

// 统一前缀
const router = new Router({prefix: '/items'});

// 增删改查
router.post('/add', tokenValidator, itemsFormValidator, addItems);
router.post('/update', tokenValidator, idValidator, itemsFormValidator, updateItems);
router.get('/list', tokenValidator, queryItems);
router.get('/detail', tokenValidator, idValidator, queryItemsDetail);
router.post('/delete', tokenValidator, idValidator, deleteItems);


module.exports = router;